package com.controller;

import com.dao.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Controller;
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;

import javax.servlet.http.HttpServletRequest;

@Controller
public class HomeController {

    @Autowired
    private UserService userService;

    @RequestMapping("/")
    public String index(Model model, HttpServletRequest request) {

        String realPath = request.getServletContext().getRealPath("/");

        Object username = userService.getByUsername("xiaosu");
        System.out.println("controller:" + username);
        System.out.println("realPath:" + realPath);
        model.addAttribute("name", "spring-value");
        return "index";
    }
}
